﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GTP.AppFrame.PrototypeTools.Common;

namespace GTP.AppFrame.PrototypeTools.Business
{
    /// <summary>
    /// 业务相关的属性，即用户的输入
    /// </summary>
    public class BizProperty
    {
        #region 基本属性
        /// <summary>
        /// 名称
        /// {GTP-PT:Name}
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 显示名称
        /// {GTP-PT:DisplayName}
        /// </summary>
        public string DisplayName { get; set; }
        /// <summary>
        /// 命名空间
        /// {GTP-PT:Namespace}	
        /// </summary>
        public string BizNameSpace { get; set; }
        /// <summary>
        /// 包名
        /// {GTP-PT:PackageName}
        /// </summary>
        public string BizPackageName { get; set; }
        /// <summary>
        /// 父表单
        /// {GTP-PT:ParentName}
        /// </summary>
        public string ParentName { get; set; }
        /// <summary>
        /// 父单据的包名
        /// {GTP-PT:ParentPackage}
        /// </summary>
        public string ParentPackage { get; set; }
        /// <summary>
        /// 父表单对应的表
        /// {GTP-PT:ParentTable}
        /// </summary>
        public string ParentTable { get; set; }
        #endregion

        /// <summary>
        /// 单据模板
        /// </summary>
        public BizFormTemplate FormTemplate { get; set; }
        /// <summary>
        /// 主实体属性
        /// </summary>
        public List<EntityProperty> MainEntityPropetyList { get; set; }
        /// <summary>
        /// 子实体
        /// </summary>
        public List<SubEntity> SubEntityList { get; set; }

        /// <summary>
        /// 把基本属性数据填充到所给的字符串中，即替换所有{GTP-PT:XXX}的字符串
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string Fill(string data)
        {
            data = data.Replace("{GTP-PT:Name}", Name).Replace("{GTP-PT:DisplayName}", DisplayName)
                .Replace("{GTP-PT:Namespace}", BizNameSpace).Replace("{GTP-PT:PackageName}", BizPackageName)
                .Replace("{GTP-PT:ParentPackage}", ParentPackage).Replace("{GTP-PT:ParentName}", ParentName)
                .Replace("{GTP-PT:ParentTable}", ParentTable);
            return data;
        }
    }
}
